<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>6_4_2-自定义指令的参数</title>
</head>

<body>


  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <div id="Application">
    <input v-getfocus:custom="1" />
    <!--<input v-getfocus:custom="{a:1, b:2}" />-->
  </div>
  <script>
    const App = Vue.createApp({});
    App.directive("getfocus", {
      //当绑定此指令的元素被挂载时调用
      mounted(element, param) {
        if (param.value == "1") {
          element.focus();
        }
        //将打印参数：custom
        console.log("参数：" + param.arg);
      },
    });
    App.mount("#Application");
  </script>
</body>

</html>